package router

import (
	"Data-API-MCP/backend/internal/interfaces/http/handler"

	"github.com/gin-gonic/gin"
)

// RegisterDBRoutes 注册数据库连接相关路由
func RegisterDBRoutes(r *gin.RouterGroup, dbHandler *handler.DBHandler) {
	dbGroup := r.Group("/connections")
	{
		// 数据库连接管理
		dbGroup.POST("/createConnection", dbHandler.CreateConnection) // 创建连接
		dbGroup.POST("/getConnectionList", dbHandler.GetConnections)  // 获取连接列表
		dbGroup.POST("/:id", dbHandler.GetConnection)                 // 获取单个连接
		dbGroup.PUT("/:id", dbHandler.UpdateConnection)               // 更新连接
		dbGroup.DELETE("/:id", dbHandler.DeleteConnection)            // 删除连接
		dbGroup.POST("/test", dbHandler.TestConnection)               // 测试连接

		// 数据库操作
		dbGroup.GET("/:id/tables", dbHandler.GetTables)                 // 获取表列表
		dbGroup.GET("/:id/tables/:table", dbHandler.GetTableInfo)       // 获取表信息
		dbGroup.GET("/:id/tables/:table/columns", dbHandler.GetColumns) // 获取列信息
		dbGroup.GET("/:id/tables/:table/data", dbHandler.GetTableData)  // 获取表数据
		dbGroup.POST("/:id/query", dbHandler.ExecuteQuery)              // 执行查询
	}
}
